package tests;

import static helper.Util.*;
import javax.vecmath.Point3d;
import primitive3D.Cube;
import rayCaster.Ray;


public class TestCube {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Cube cube = new Cube();
		System.out.println(cube);
		/*
		ArrayList<Primitive3D>primList = cube.getPrimitives();
		
		for( int i=0 ; i< primList.size() ; i++ ){
			System.out.println(primList.get(i));
		}

		//Test the scale method
		System.out.println("\n=========> TESTING SCALE");		
		cube.scale(2);		
		System.out.println(cube);
		primList = cube.getPrimitives();		
		for( int i=0 ; i< primList.size() ; i++ ){
			System.out.println(primList.get(i));
		}
		
		
		//test translate
		cube.setPosition(new Point3d(1.5,1.5,0.5));
		System.out.println("\n==========> TESTING TRANSLATION");
		System.out.println(cube);
		
		for( int i=0 ; i< primList.size() ; i++ ){
			System.out.println(primList.get(i));
		}
		*/
		// Test de interseccion
		
		// Corta un solo punto
		Point3d origin = new Point3d(0,0,0); 
		Point3d dir = new Point3d(1,1,0);
		Ray ray = new Ray(origin, dir);
		/*
		// No corta ningun punto
		Point3d origin = new Point3d(7,0,0); 
		Vector3d vecDir = new Vector3d(1,1,0);
		Ray ray = new Ray(origin, vecDir);
		*/
		System.out.println(ray);
		
		Point3d[] pts = new Point3d[2];
		pts[0] = new Point3d();
		pts[1] = new Point3d();
		try {
			int cant = cube.intersects(ray, pts);
			System.out.println("cant: " + cant);
			System.out.println("pts: " + show(pts));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
